import React from 'react';
import ReactDOM from 'react-dom';
import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom'
import { Provider } from 'react-redux'
import { mainRoutes } from './routes'
import App from './App';
import store from './store'

import { 
  ConfigProvider
} from 'antd';
import './index.less';

console.log('store', store.getState())

// const myLocale = () => require('antd/es/locale/'+store.getState().lang.locale)


ReactDOM.render(
  <Provider store={store}>
    <ConfigProvider locale={ store.getState().lang.locale }>
      <Router>
        <Switch>
          <Route 
            path="/admin" 
            component={App} 
            // render={(routerProps) => {
            //   // 后期要做权限校验
            //   return store.getState().user.isLogin? <App {...routerProps} /> : <Redirect to="/login" />
            // }} 
          />
          {
            mainRoutes.map(route => {
              return <Route key={route.pathname} path={route.pathname} component={route.component} />
            })
          }
          <Redirect to="/admin" exact from="/" />
          <Redirect to="/404" />
        </Switch>
      </Router>
    </ConfigProvider>
  </Provider>,
  document.getElementById('root')
);
